#ifndef _THREAD_STATIC_H_
#define _THREAD_STATIC_H_

#include <windows.h>

#ifdef _WIN32
    typedef HANDLE THREAD_HANDLE;
#else
    typedef pthread_t THREAD_HANDLE;
#endif

class CThreadStatic
{
public:
    CThreadStatic();
    virtual ~CThreadStatic();

public:
    virtual bool create();
    THREAD_HANDLE getHandle();
    void osSleep(int nSeconds);
    void sleepMs(int nMilliSeconds);
    bool join();
    bool isCurrentThread();
    void exitThread();

private:
#ifdef _WIN32
    static DWORD WINAPI _ThreadEntry(LPVOID pParam);
#else
    static void* _ThreadEntry(void* pParam);
#endif // _WIN32
    virtual bool initInstance();
    virtual void exitInstance();
    virtual void run() = 0;

private:
#ifdef _WIN32
    DWORD m_idThread;
#endif
    THREAD_HANDLE m_hThread;
};

#endif